// 外来组件加载控件变量
var arcGISObject = {hasInitFinsh:false, initFinshEvent:null};
var cesiumObject = {hasInitFinsh:false, initFinshEvent:null};
var echartsObject = {hasInitFinsh:false, initFinshEvent:[]};
var editObject = {hasInitFinsh:false, initFinshEvent:[]};

require.config({
    baseUrl: './',
    paths: {
        'jquery-easyui' : 'http://localhost/web-base/jquery-easyui/v1.5.2/jquery.easyui.min',
        'jquery-easyui-zh' : 'http://localhost/web-base/jquery-easyui/v1.5.2/locale/easyui-lang-zh_CN',

        'angular': 'http://localhost/web-base/angular/v1.3.0/angular.min',
        'angular-route': 'http://localhost/web-base/angular/v1.3.0/angular-route.min',
        'angular-ui-router': 'http://localhost/web-base/angular/v1.3.0/angular-ui-router.min',
        'angular-async-loader': 'http://localhost/web-base/angular-async-loader/angular-async-loader.min',

        'easyui': 'http://localhost/angular-base/dest/ui/easyui',
        'form': 'http://localhost/angular-base/dest/form/form',
        'security': 'http://localhost/angular-base/dest/security/security.min',
        'arcgis3' :'http://localhost/angular-base/dest/gis/arcgis3',
        'gis' :'http://localhost/angular-base/dest/gis/gis',
        'arcgis_analysis':'app-js/arcgis-analysis-base',
        'app' : 'app',
        'app-routes': 'app-routes',
        
        'echarts':'http://localhost/web-base/echarts/echarts.min',
        'echarts-pie':'http://localhost/angular-base/angular-echarts/echarts-pie',
        'echarts.china':'http://localhost/web-base/echarts/china.map',
        'ui.echarts':'http://localhost/angular-base/angular-ui/extend/charts/ui-echarts',

        'plupload':'http://localhost/web-base/plupload/v2.1.4/plupload.full.min',
        'plupload.queue':'http://localhost/web-base/plupload/v2.1.4/jquery.plupload.queue/jquery.plupload.queue.min',
        'plupload.i18n':'http://localhost/web-base/plupload/v2.1.4/i18n/zh_CN',

        'as-files' : 'http://localhost/angular-base/angular-ui/extend/upload/as-files',
        'ui-upload' : 'http://localhost/angular-base/angular-ui/extend/upload/ui-upload',

        'kindeditor':'http://localhost/web-base/kindeditor/v4.1.11/kindeditor-all',
        'kindeditor.i18n':'http://localhost/web-base/kindeditor/v4.1.11/zh-CN',
        'ui-edit':'http://localhost/angular-base/angular-ui/extend/edit/ui-edit'
    },
    packages: [
        { name: 'bmap', location: "http://localhost/web-base/arcgis/extent/bmap" },
        { name: 'tdmap', location: "http://localhost/web-base/arcgis/extent/tdmap" },
        { name: 'dijit', location: "http://localhost/web-base/arcgis/v3.21/dijit" },
        { name: 'dojo', location: "http://localhost/web-base/arcgis/v3.21/dojo" },
        { name: 'dojox', location: "http://localhost/web-base/arcgis/v3.21/dojox" },
        { name: 'esri', location: "http://localhost/web-base/arcgis/v3.21/esri" },
        { name: 'moment', location: "http://localhost/web-base/arcgis/v3.21/moment" }
    ],
    shim: {
        'angular': {exports: 'angular'},
    	'angular-route': {deps: ['angular']},
        'angular-ui-router': {deps: ['angular']},
        'angular-async-loader': {deps: ['angular']},

        'easyui': {deps: ['angular']},
        'form': {deps: ['angular']},
        'security' : {deps: ['angular']},
        'arcgis3' :{deps: ['angular']},
        'gis' :{deps: ['angular']},
        
        'app-routes' : {deps: ['angular']},

        'kindeditor.i18n':{deps: ['kindeditor']},
        'ui-edit':{deps: ['angular']},

        'plupload':{exports: 'plupload'},
        'plupload.queue':{deps: ['plupload']},
        'plupload.i18n':{deps: ['plupload']},
        'as-files' :{deps: ['angular']},
        'ui-upload' :{deps: ['angular']}
    }
});

// angular app 加载
require(['angular','app','app-routes'], function (angular) {
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['app']);
        angular.element(document).find('html').addClass('ng-app');
    });
});

// arcgis 2d 地图加载
require([
    'bmap/bMapVeclayer',
    'bmap/bMapImglayer',
    'bmap/bMapAnolayer',

    'tdmap/tdMapAnnoLayer',
    'tdmap/tdMapLayer',
    'tdmap/tdMapImgAnnoLayer',
    'tdmap/tdMapImgLayer',

    'dojo/parser',
    'dojo/domReady!',

    'esri/map',
    'esri/layers/WMSLayer',
    'esri/layers/WMTSLayer', 
    'esri/layers/WMTSLayerInfo',
    'esri/layers/ImageParameters',
    'esri/layers/ArcGISImageServiceLayer', 
    'esri/layers/ImageServiceParameters',
    'esri/layers/GraphicsLayer',
    'esri/layers/ArcGISDynamicMapServiceLayer',

    'esri/tasks/locator',
    'esri/tasks/geometry',
    'esri/tasks/query',
    'esri/tasks/PrintTask',
    'esri/tasks/PrintTemplate',
    'esri/tasks/PrintParameters',
    'esri/tasks/IdentifyTask',
    'esri/tasks/IdentifyParameters',
    'esri/tasks/FindTask',
    'esri/tasks/FindParameters',

    'esri/graphic',
    'esri/geometry/Point',
    'esri/geometry/Polygon',
    'esri/geometry/Extent',
    'esri/SpatialReference',
    'esri/toolbars/navigation',
    'esri/toolbars/draw',

    "esri/dijit/Scalebar",
    
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleFillSymbol'
    ], function (bMapVeclayer,bMapImglayer,bMapAnolayer,
        tdMapAnnoLayer,tdMapLayer,tdMapImgAnnoLayer,tdMapImgLayer) { 
        arcGISObject.hasInitFinsh=true;
        if(arcGISObject.initFinshEvent){
            arcGISObject.initFinshEvent();
        }
        
        arcGISObject.bmapVeclayer = new bMapVeclayer();
        arcGISObject.bmapImglayer = new bMapImglayer();
        arcGISObject.bmapAnolayer = new bMapAnolayer();

        arcGISObject.tdmapAnnoLayer = new tdMapAnnoLayer();
        arcGISObject.tdmapLayer = new tdMapLayer();
        arcGISObject.tdmapImgAnnoLayer = new tdMapImgAnnoLayer();
        arcGISObject.tdmapImgLayer = new tdMapImgLayer();
    }
);